import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger/dist/decorators';
import { GetAccessTokenDto } from './dto/get-access-token.dto';
import { GetCodeSessionDto } from './dto/get-code-session.dto';
import { GetPhoneNumberDto, GetPhoneNumberQuery } from './dto/get-phone-number.dto';
import { WxapiService } from './wxapi.service';

@ApiTags('小程序Api')
@Controller('wxapi')
export class WxapiController {
  constructor(private readonly wxapiService: WxapiService) {}

  @Get('getAccessToken')
  async getAccessToken(@Query() query: GetAccessTokenDto) {
    return await this.wxapiService.getAccessToken(query)
  }

  @Post('getPhoneNumber')
  async getPhoneNumber(@Query() query: GetPhoneNumberQuery, @Body() dto: GetPhoneNumberDto) {
    return await this.wxapiService.getPhoneNumber(query, dto)
  }

  @Post('getCodeSession')
  async getCodeSession(@Body() dto: GetCodeSessionDto) {
    return await this.wxapiService.getCodeSession(dto)
  }
}
